package com.yaozheng.vocationaltraining.fragment;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.ViewById;

import com.bumptech.glide.Glide;
import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.iview.IItemView;
import com.yaozheng.vocationaltraining.utils.BitmapLoader;
import com.yaozheng.vocationaltraining.utils.ErrorUtils;
import com.yaozheng.vocationaltraining.utils.ImageUtils;

import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;

/**
 * 一项课件图片
 *
 * @author Administrator
 */
@EFragment(R.layout.item_fragment_courseware_image)
public class ItemCoursewareImageFragment extends BaseFragment {
    @ViewById
    ImageView itemCoursewareImage;
    @ViewById
    TextView courewareWatermarkTextView;
    @FragmentArg
    int position;
    @FragmentArg
    String imageUrl, watermarkName;

    IItemView iItemView;

    boolean isFullScreen;


    public void setIItemView(IItemView iItemView) {
        this.iItemView = iItemView;
    }

    public boolean isFullScreen() {
        return isFullScreen;
    }

    public void setFullScreen(boolean isFullScreen) {
        this.isFullScreen = isFullScreen;
    }

    @AfterViews
    public void initView() {
        // try {
        // itemCoursewareImage.setImageResource(R.drawable.ppt_image1
        // + position);

        // } catch (Exception e) {
        // itemCoursewareImage.setImageResource(R.drawable.ppt_image1);
        // }
        // itemCoursewareImage.setImageResource(R.drawable.ppt_image1);

//        if (isFullScreen) {
//            itemCoursewareImage.setScaleType(ScaleType.CENTER);
//        } else {
//        itemCoursewareImage.setScaleType(ScaleType.FIT_XY);

//        }
        // if (iImageLoaderOptions != null) {
        // ImageLoader.getInstance().displayImage(imageUrl,
        // itemCoursewareImage,
        // iImageLoaderOptions.getDisplayImageOptions());
        // } else {
        // ImageLoader.getInstance().displayImage(imageUrl,
        // itemCoursewareImage);
        // }
        try {
            getBaseActivity().getDefaultBitmapLoader().displayImage(imageUrl, itemCoursewareImage);
        } catch (Exception ex) {
            ErrorUtils.outErrorLog(ex);
        }
        if (watermarkName == null) {
            watermarkName = "jack";
        }
        courewareWatermarkTextView.setText(watermarkName);
    }

    @Click(R.id.itemCoursewareImage)
    public void itemCoursewareImageClick() {
        if (iItemView != null) {
            iItemView.itemClick(position);
        }

    }
}
